<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class krs_approve extends CI_Controller {
	
	function __construct(){
		parent::__construct();
		$this->load->model('mdl_krs_approve');
		$this->load->model('mdl_mahasiswa');
		
		//$this->output->enable_profiler(TRUE);
	}
	
	function index(){
		$this->load->view('krs_approve');
	}
	
	# grid
	function grid(){
		$data = $this->mdl_krs_approve->getdata();
		echo $this->mdl_krs_approve->togrid($data['row_data'], $data['row_count']);
	}
	
	function grid_detail($id){
		$data = $this->mdl_krs_approve->getdata_detail($id);
		echo $this->mdl_krs_approve->togrid($data['row_data'], $data['row_count']);
	}
	# end grid
	
	function approve($id){
		# init
		$status = "";
		$result = false;
		$data['pesan_error'] = '';
		
		$result = $this->mdl_krs_approve->approve($id, 'Approve');
		
		if($result){
			echo json_encode(array('success'=>true));
		}else{
			echo json_encode(array('msg'=>$data['pesan_error']));
		}
	}

}